package com.lhh.jiu.controller;

import com.lhh.jiu.data.Result;
import com.lhh.jiu.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@Controller
public class FileController {
    @Autowired
    FileService fileService;
    @RequestMapping("/toupload")
    public String to(){
        return "upload";
    }

    @RequestMapping("/upload")
    @ResponseBody
    public Result uploadsFile(@RequestParam("head_img") MultipartFile file, HttpServletRequest request){
        String name = request.getParameter("name");//name信息
        System.out.println("用户名："+name);

        return fileService.upload(file);
    }
}

